<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>新增用户</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
        <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
        <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
    </head>
    <body style="padding:10px;">
        <div class="tplay-body-div">
            <div class="layui-tab">
                <ul class="layui-tab-title">
                    <li><a href="{:url('admin/ldapuser/userList')}" class="a_menu">用户管理</a></li>
                    <li class="layui-this">{notempty name="$userInfo.uid"}编辑用户{else}新增用户{/notempty}</li>
                </ul>
            </div> 
            <div style="margin-top: 20px;">
            </div>
            <form class="layui-form" id="admin">

                <div class="layui-form-item">
                    <label class="layui-form-label">账号</label>
                    <div class="layui-input-inline">
                        <input name="second_name" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" type="text" {notempty name="$userInfo.uid"} value="{$userInfo.uid}" disabled {/notempty}>
                    </div>
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-inline">
                        <input name="display_name" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" type="text" {notempty name="$userInfo.displayname"}value="{$userInfo.displayname}"{/notempty}>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">邮箱地址</label>
                    <div class="layui-input-inline">
                        <input name="email" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" type="text" {notempty name="$userInfo.mail"}value="{$userInfo.mail}"{/notempty}>
                    </div>
                    <label class="layui-form-label">所属组</label>
                    <div class="layui-input-inline">
                        <select multiple lay-search id="groupSelect" name="group">
                            <option>请选择分组</option>
                            {$option}
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">用户属性</label>
                    <div class="layui-input-inline">
                        <select name="employeetype" lay-filter="aihao">
                            <option value="">请选择用户属性</option>            
                            <option value="developer" {notempty name="$userInfo.employeetype"}{eq name="$userInfo.employeetype" value="developer"} selected=""{/eq}{/notempty}>developer</option>
                        </select>
                    </div>
                    <label class="layui-form-label">用户电话</label>
                    <div class="layui-input-inline">          
                        <input name="phone" placeholder="请输入" autocomplete="off" class="layui-input" type="text" {notempty name="$userInfo.mobile"}value="{$userInfo.mobile}"{/notempty}>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">用户密码</label>
                    <div class="layui-input-inline">
                        <input name="password" lay-verify="pass" placeholder="请输入密码" autocomplete="off" class="layui-input" type="text">
                    </div>
                    {notempty name="$userInfo.uid"}
                    <div class="layui-form-mid layui-word-aux">如果不需要修改密码，此处留空</div>
                    <input type="hidden" name="id" value="{$userInfo.uid}"/>
                    {/notempty}
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="*">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>

            </form>
            <div class="unshow">
                <pre id="result">

                </pre>
            </div>

            <script src="__PUBLIC__/layui/layui.js"></script>
            <script src="__PUBLIC__/jquery/jquery.min.js"></script>
            <script>
                var message;
                layui.config({
                    base: '__JS__/',
                    version: '1.0.1'
                }).use(['app', 'message'], function () {
                    var app = layui.app,
                            $ = layui.jquery,
                            layer = layui.layer;
                    //将message设置为全局以便子页面调用
                    message = layui.message;
                    //主入口
                    app.set({
                        type: 'iframe'
                    }).init();
                });

                layui.use(['layer', 'form'], function () {
                    var layer = layui.layer,
                            $ = layui.$,
                            form = layui.form;
                    form.on('submit(*)', function (data) {
                        console.log(data.field);
                        $.ajax({
                            url: "{:url('admin/ldapuser/publish')}",
                            data: data.field,
                            type: 'post',
                            async: true,
                            success: function (res) {
                                if (res.code == 1) {
                                    layer.alert(res.msg, function (index) {
                                        location.href = res.url;
                                    })
                                } else {
                                    layer.msg(res.msg);
                                }
                            }
                        })
                        return false;
                    });
                });

            </script>
        </div>
    </body>
</html>